import React from 'react'
import {Router} from 'dva/router'
import App from './routes/app'

function RouterConfig({history}){
    const routes=[{
        path:'/',
        component:App,
        getIndexRoute(nextState,cb){
            require.ensure([],require=>{
                app.model(require('./models/resourceManage'))
                cb(null,{component:require('./routes/resourceManage')})
            })
        },
        childRoutes:[
            {
                path:'resourceManage',
                name:'resourceManage',
                getComponent(nextState,cb){
                    require.ensure([],require=>{
                        app.model(require('./models/resourceManage'))
                        cb(null,require('./routes/resourceManage'))
                    })
                }
            },
            {
                path:'wiki',
                name:'wiki',
                getComponent(nextState,cb){
                    require.ensure([],require=>{
                        app.model(require('./models/wiki'))
                        cb(null,require('./routes/wiki'))
                    })
                }
            },
            {
                path:'wechatTip',
                name:'wechatTip',
                getComponent(nextState,cb){
                    require.ensure([],require=>{
                        app.model(require('./models/wechatTip'))
                        cb(null,require('./routes/wechatTip'))
                    })
                }
            },
            {
                path:'authorization',
                name:'authorization',
                getComponent(nextState,cb){
                    require.ensure([],require=>{
                        app.model(require('./models/authorization'))
                        cb(null,require('./routes/authorization'))
                    })
                }
            }，
            {
                path:'＊',
                name:'error',
                getComponent(nextState,cb){
                    require.ensure([],require=>{
                        cb(null,require('./routes/error'))
                    })
                }
            }
        ]

    }]
    return <Router history={history} routes={routes}/>
}

export default RouterConfg
